package com.cs.bd.ad.sdk;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;

import java.lang.ref.WeakReference;

public abstract class SdkAdContext extends ContextWrapper {
    private WeakReference<Activity> mActivityWeRef;

    public SdkAdContext(Context base, Activity activity) {
        super(base);
        if (activity != null) {
            this.mActivityWeRef = new WeakReference(activity);
        }

    }

    public abstract boolean needPassActivity2FbNativeAd();

    public Activity getActivity() {
        return this.mActivityWeRef != null ? (Activity)this.mActivityWeRef.get() : null;
    }

    public Context getContext() {
        Activity activity = this.getActivity();
        if (this.needPassActivity2FbNativeAd() && activity != null) {
            return activity;
        } else {
            return this;
        }
    }
}